package com.aloha.springframework.context.annotation;

import cn.hutool.core.util.ClassUtil;
import com.aloha.springframework.beans.factory.config.BeanDefinition;
import com.aloha.springframework.stereotype.Component;

import java.util.Set;
import java.util.stream.Collectors;


public class ClassPathScanningCandidateComponentProvider {

    /**
     * 找到指定包下有Component的类，并将它们封装成Bean定义信息
     */
    public Set<BeanDefinition> findCandidateComponents(String basePackage) {
        return ClassUtil.scanPackageByAnnotation(basePackage, Component.class).stream().map(BeanDefinition::new).collect(Collectors.toSet());
    }
}
